<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Js数据类型</title>
</head>
<body>
<script>
    //JS数据类型 = 原始类型 + 引用类型
    //原始类型: number string boolean null undefined
    var a = 1;
    var b = 6.6;
    console.log(a,typeof a);
    console.log(b,typeof b);
    var c = '你好';
    var d = "你们好";
    console.log(c,typeof c);
    console.log(d,typeof d);
    var e = true;
    var f = false;
    console.log(e,typeof e);
    console.log(f,typeof f);

    //声明了一个变量g,但是没有赋值,此时g的值为undefined
    var g;
    console.log(g, typeof g);//undefined "undefined"

    //引用数据类型: Object Number String Boolean Array Function
    //1)自定义JS对象
    var obj = {
        name: "张三",
        age: 18,
        sex: "男"
    };
    console.log(obj, typeof obj);//{name: "张三", age: 18
    console.log(obj.name, typeof obj.name);//张三 "string"

    obj.age = 20;//修改属性值
    console.log(obj.age);//20
    //2)JS对象的属性可以动态添加
    obj.like = "打篮球";//like属性不存在,动态添加
    console.log(obj.like);//打篮球
    console.log(obj);

    console.log(obj.play);//访问不存在的属性,返回undefined

    //3)JS对象的属性可以动态删除
    delete obj.like;
    console.log(obj);
    console.log(obj.like);//undefined

    //JS数组
    let arr = ['李逵', '鲁班','后羿',1, 2.6, false];
    console.log(arr, typeof arr);//["李逵", "鲁班", "后羿", 1, 2.6, false] "object"
    console.log(arr[0], typeof arr[0]);//李逵 "string"
    console.log(arr[5], typeof arr[5]);//false "boolean"
    console.log(arr[99], typeof arr[99]);//访问不存在的下标 undefined "undefined"





</script>
</body>
</html>